package io.valuesfeng.picker.model;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Created by Dune on 16/7/11.
 */
public class CropParams implements Parcelable {

    public static final String TAG = "crop_params";
    public static final int CROP_IMAGE_REQUEST_CODE = 2001;
    public static final Creator<CropParams> CREATOR = new Creator<CropParams>() {
        @Override
        public CropParams createFromParcel(Parcel source) {
            return new CropParams(source);
        }

        @Override
        public CropParams[] newArray(int size) {
            return new CropParams[size];
        }
    };
    public int aspect_x = 1;
    public int aspect_y = 1;
    public int max_x;
    public int max_y;
    public String cacheDir = "cropped";

    public CropParams(int aspect_x, int aspect_y, int max_x, int max_y) {
        this.aspect_x = aspect_x;
        this.aspect_y = aspect_y;
        this.max_x = max_x;
        this.max_y = max_y;
    }

    public CropParams(int max_x, int max_y) {
        this.max_x = max_x;
        this.max_y = max_y;
    }

    public CropParams() {
    }

    protected CropParams(Parcel in) {
        this.aspect_x = in.readInt();
        this.aspect_y = in.readInt();
        this.max_x = in.readInt();
        this.max_y = in.readInt();
        this.cacheDir = in.readString();
    }

    public void asSquare() {

        aspect_x = aspect_x = 1;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.aspect_x);
        dest.writeInt(this.aspect_y);
        dest.writeInt(this.max_x);
        dest.writeInt(this.max_y);
        dest.writeString(this.cacheDir);
    }
}
